package sprint2;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author Vincent van Andel
 * @author Fabian Mengerink
 *
 */
public class Boot implements Serializable {

	private ArrayList<Enemy> enemies = new ArrayList<Enemy>();
	private ArrayList<Location> connectingLocations;
	private ArrayList<Location> locations;
	private ArrayList<Item> items = new ArrayList<Item>();
	private Character character;

	public void run() throws FileNotFoundException, IOException, ClassNotFoundException {
		locations();
		setCharacter(new Character(1, 90., 5., 10., 6., 7., 8, 10, 2.));
		enemies();
		items();
		getCharacter().setCurrentLocation(87);
		getCharacter().choice();
	}

	public void load() throws FileNotFoundException, IOException, ClassNotFoundException {

		getCharacter().choice();
	}

	private void enemies() {
		// Enemy(String name, String filename, double hpMax, double armour,
		// double power, double hitrating, double dodgerating, int speed,
		// double critChance, double critDamage)
		Enemy alien1 = new Enemy("", "", 20., 5., 2., 6., 6., 5, 2., 1.3);
		Enemy alien2 = new Enemy("", "", 30., 6., 3., 6., 7., 7, 3., 1.4);
		Enemy alien3 = new Enemy("", "", 40., 7., 4., 6., 7., 8, 4., 1.5);
		Enemy saveciv1 = new Enemy("Verlies", 500., 9., 8., 6., 6., 6, 2., 1.3); // character
		// verliest
		Enemy saveciv2 = new Enemy("Random", 400., 6., 5., 6., 6., 6, 2., 1.3); // spannend
		Enemy saveciv3 = new Enemy("Winst", 310., 5., 3., 6., 6., 5, 2., 1.3); // character
		// wint
		enemies.add(alien1);
		enemies.add(alien2);
		enemies.add(alien3);
		enemies.add(saveciv1);
		enemies.add(saveciv2);
		enemies.add(saveciv3);

		// Enemies in Gevechtschip
		enemies.add(new Enemy("Dalien", "", 15., 3., 2., 6., 6., 5, 2., 1.1));
		enemies.add(new Enemy("Malien", "", 20., 4., 3., 6., 6., 6, 3., 1.2));
		enemies.add(new Enemy("Shalien", "", 22., 4., 3.4, 6., 6., 6, 3., 1.2));
		enemies.add(new Enemy("Zalien", "", 65., 2., 1., 3., 6., 2, 3., 1.1));
		enemies.add(new Enemy("Qualien", "", 30., 4., 3., 6., 6., 20, 3., 1.4));
		enemies
				.add(new Enemy("Minailien", "", 1, 40., .6, 14., 6., 100, 4,
						2.5));
		enemies.add(new Enemy("Talien", "", 27., 6., 7., 5., 6., 2, 2., 1.5));
		enemies.add(new Enemy("Cisharilien", "", 72., 5., 7., 6., 7., 9, 5., 1.6));
		enemies.add(new Enemy("Whiner", "", 15., 3., 2., 6., 6., 5, 2., 1.1));
		enemies.add(new Enemy("Die Rooie", "", 22., 4., 3.4, 6., 6., 6, 3., 1.2));
		enemies.add(new Enemy("Whinertje", "", 15., 3., 2., 6., 6., 5, 2., 1.1));
		enemies.add(new Enemy("Anita", "", 30., 4., 3., 6., 6., 20, 3., 1.4));
		enemies.add(new Enemy("Sjonnie", "", 20., 4., 3., 6., 6., 6, 3., 1.2));
		enemies.add(new Enemy("Quickie", "", 1, 40., .6, 14., 6., 100, 4,2.5));
		enemies.add(new Enemy("Shenkie", "", 72., 5., 7., 6., 7., 9, 5., 1.6));
		}

	private void items() {
		items.add(new Key("Sleutelkaart 1", "Sleutelkaart nodig voor eerste teleporter", 20., 1));
		items
				.add(new Creature("Driekoppige aap",
						"Een aap met drie koppen..."));
		items.add(new BigCreature("Artisjokeekhoorn",
				"Een rare eekhoorn, die de hele dag artisjokken eet."));
		items.add(new Creature("Pluimvoetbij", "Een bij met rode broeken."));
		items.add(new BigCreature("Eendgorilla", "Een gorilla met snavel."));
		items.add(new Creature("Blaffende Zebravink",
				"Een vogel met hondenkop."));
		items
				.add(new Creature("Punkkikker",
						"Een kikker met een ring in zijn neus en een mond met zipper."));
		items.add(new Creature("Pinkat", "Een pinguin met kattenkop."));
		items.add(new Creature("Papehondgaai",
				"Een papegaai en een hond tegelijk."));
		items
				.add(new BigCreature("Pindaolifant",
						"Een olifant met pindasaus."));
		// ShrinkGun om BigCreatures te krimpen
		items.add(new ShrinkGun("Krimpistool",
				"Pistool, om grote wezens te krimpen", 0));
		// Net om creatures mee te vangen
		items.add(new CatchingNet("Vangnet",
				"Gebruik het om wezens te vangen", 0, 0.7));

		items.add(new Key("Shelren Teleporter Sleutelkaart", "Sleutel nodig voor Shelren's teleporter", 1., 2));
		items.add(new Key("Gevechtsschip Kaart C", "Sleutel nodig voor een deur in het gevechtsschip", 20., 3));
		items.add(new Key("Gevechtsschip Kaart H", "Sleutel nodig voor een deur in het gevechtsschip", 20., 4));
		items.add(new BattleShipControlPanel("Gevechtsschip Controlepaneel", "Het paneel die wordt gebruikt om andere schepen mee aan te vallen.", 0));
		items.add(new Key("Vervallen Wereld Key", "Sleutel nodig voor toegang tot vervallen wereld", 1., 5));
	}
	

	private void locations() throws FileNotFoundException, IOException, ClassNotFoundException {
		Location chamber1 = new Chamber("Ingang", "kamer1.txt", 1, 2, 3, 4, 0,
				0, 0, 0);
		Location chamber2 = new Chamber("Hal", "kamer2.txt", 2, 1, 7, 0, 0, 0,
				0, 0);
		Location chamber3 = new Chamber("Zijkamer", "kamer3.txt", 3, 1, 0, 0,
				0, 0, 0, 0);
		Location chamber4 = new Chamber("Tussenkamer", "kamer4.txt", 4, 1, 5,
				0, 0, 0, 0, 0);
		Location teleport5 = new Teleport("Teleporter", "kamer5.txt", 5, 4, 6,
				0, 0, 0, 0, 0, 1);
		Location chamber6 = new Chamber("Planeet1", "kamer6.txt", 6, 8, 0, 0,
				0, 0, 0, 0);
		Location chamber7 = new Chamber("Keykamer", "kamer7.txt", 7, 2, 0, 0,
				0, 0, 1, 0); // ook de locatie van de key
		Location chamber8 = new Chamber("Planeet2", "kamer8.txt", 8, 9, 10, 0,
				0, 0, 0, 0);
		Location chamber9 = new Chamber("Planeet3", "kamer9.txt", 9, 10, 8, 0,
				0, 0, 0, 0);
		Location chamber10 = new Chamber("Planeet4", "kamer10.txt", 10, 9, 8,
				11, 0, 0, 0, 0);
		Location chamber11 = new Chamber("Planeet5", "kamer11.txt", 11, 10, 12,
				0, 0, 0, 0, 0);
		Location ruimteschip = new Chamber("Ruimteschip", "kamer12.txt", 12,
				13, 11, 0, 0, 0, 0, 0);
		Location schip1 = new Spaceship("Welkomsruimte", "kamer13.txt", 13, 14,
				12, 0, 0, 0, 0, 0);
		Location schip2 = new Spaceship("Commandcenter", "kamer14.txt", 14, 13,
				25, 27, 28, 87, 0, 4);
		Location artichokeplanet12 = new Chamber("Artisjokkenwoud Ruimteschip",
				"artichokeplanet12.txt", 25, 15, 14, 0, 0, 0, 11, 0);
		Location artichokeplanet1 = new Chamber("Artisjokkenwoud1",
				"artichokeplanet1.txt", 15, 25, 16, 0, 0, 0, 2, 0);
		Location artichokeplanet2 = new Chamber("Artisjokkenwoud2",
				"artichokeplanet2.txt", 16, 15, 17, 18, 0, 0, 3, 0);
		Location artichokeplanet3 = new Chamber("Artisjokkenwoud3",
				"artichokeplanet3.txt", 17, 16, 20, 0, 0, 0, 4, 0);
		Location artichokeplanet4 = new Chamber("Artisjokkenberg",
				"artichokeplanet4mountain.txt", 18, 16, 19, 0, 0, 0, 5, 0);
		Location artichokeplanet5 = new Chamber("Artisjokkenbergtop",
				"artichokeplanet5mountain.txt", 19, 18, 0, 0, 0, 0, 6, 0);
		Location artichokeplanet6 = new Chamber("Artisjokkenwoud4",
				"artichokeplanet6.txt", 20, 17, 26, 0, 0, 0, 7, 0);
		Location artichokeplanet11 = new Chamber("Artisjokkenwoud Kamp",
				"artichokeplanet11.txt", 26, 20, 21, 0, 0, 0, 12, 0);
		Location artichokeplanet7 = new Chamber("Artisjokkenwoestijn1",
				"artichokeplanet7.txt", 21, 26, 22, 0, 0, 0, 8, 0);
		Location artichokeplanet8 = new Chamber("Artisjokkenwoestijn2",
				"artichokeplanet8.txt", 22, 21, 23, 0, 0, 0, 9, 0);
		Location artichokeplanet9 = new Chamber("Artisjokkenwoestijn3",
				"artichokeplanet9.txt", 23, 22, 24, 0, 0, 0, 10, 0);
		Location artichokeplanet10 = new Arkschip(
				"Artisjokkenwoestijn Arkschip", "artichokeplanet10arkship.txt",
				24, 23, 0, 0, 0, 0, 0, 0);
		Location SaveCiv = new Chamber("Save Civilization",
				"artichokeplanet10arkship.txt", 27, 0, 0, 0, 0, 0, 0, 0);
		Location battleshipquest1 = new Chamber("Shelren Ru�ne", "battleshipquest1.txt", 28, 14, 29, 0, 0, 0, 0, 0);
		Location battleshipquest2 = new Chamber("Shelren Gebouw", "battleshipquest2.txt", 29, 28, 30, 0, 0, 0, 13, 0);
		Location battleshipquest3 = new Teleport("Shelren Teleporter", "battleshipquest3.txt", 30, 29, 31, 0, 0, 0, 0, 0, 2);
		Location battleship1 = new Chamber("Gevechtsschip1", "battleship1.txt", 31, 32, 34, 0, 0, 0, 0, 0);
		Location battleship2 = new Chamber("Gevechtsschip2", "battleship2.txt", 32, 31, 33, 0, 0, 0, 0, 9);
		Location battleship3 = new Chamber("Gevechtsschip3", "battleship3.txt", 33, 32, 35, 36, 0, 0, 0, 0);
		Location battleship4 = new Chamber("Gevechtsschip4", "battleship4.txt", 34, 31, 37, 40, 42, 0, 0, 0);
		Location battleship5 = new Chamber("Gevechtsschip5", "battleship5.txt", 35, 33, 0, 0, 0, 0, 0, 10);
		Location battleship6 = new Teleport("Gevechtsschip6", "battleship6.txt", 36, 33, 67, 0, 0, 0, 0, 0, 4);
		Location battleship7 = new Chamber("Gevechtsschip7", "battleship7.txt", 37, 34, 38, 0, 0, 0, 0, 10);
		Location battleship8 = new Chamber("Gevechtsschip8", "battleship8.txt", 38, 37, 39, 0, 0, 0, 0, 0);
		Location battleship9 = new Chamber("Gevechtsschip9", "battleship9.txt", 39, 38, 0, 0, 0, 0, 14, 0);
		Location battleship10 = new Chamber("Gevechtsschip10", "battleship10.txt", 40, 34, 41, 0, 0, 0, 0, 9);
		Location battleship11 = new Chamber("Gevechtsschip11", "battleship11.txt", 41, 40, 0, 0, 0, 0, 0, 11);
		Location battleship12 = new Chamber("Gevechtsschip12", "battleship12.txt", 42, 34, 43, 0, 0, 0, 0, 0);
		Location battleship13 = new Chamber("Gevechtsschip13", "battleship13.txt", 43, 42, 44, 54, 55, 0, 0, 0);
		Location battleship14 = new Chamber("Gevechtsschip14", "battleship14.txt", 44, 43, 45, 0, 0, 0, 0, 15);
		Location battleship15 = new Chamber("Gevechtsschip15", "battleship15.txt", 45, 44, 46, 47, 0, 0, 0, 0);
		Location battleship16 = new Chamber("Gevechtsschip16", "battleship16.txt", 46, 45, 0, 0, 0, 0, 0, 12);
		Location battleship17 = new Chamber("Gevechtsschip17", "battleship17.txt", 47, 45, 48, 0, 0, 0, 0, 0);
		Location battleship18 = new Chamber("Gevechtsschip18", "battleship18.txt", 48, 47, 49, 50, 0, 0, 0, 13);
		Location battleship19 = new Chamber("Gevechtsschip19", "battleship19.txt", 49, 48, 0, 0, 0, 0, 0, 11);
		Location battleship20 = new Chamber("Gevechtsschip20", "battleship20.txt", 50, 48, 51, 0, 0, 0, 0, 0);
		Location battleship21 = new Chamber("Gevechtsschip21", "battleship21.txt", 51, 50, 52, 53, 54, 0, 0, 0);
		Location battleship22 = new Chamber("Gevechtsschip22", "battleship22.txt", 52, 51, 0, 0, 0, 0, 0, 12);
		Location battleship23 = new Chamber("Gevechtsschip23", "battleship23.txt", 53, 51, 0, 0, 0, 0, 0, 11);
		Location battleship24 = new Chamber("Gevechtsschip24", "battleship24.txt", 54, 43, 51, 0, 0, 0, 0, 0);
		Location battleship25 = new Teleport("Gevechtsschip25", "battleship25.txt", 55, 43, 56, 0, 0, 0, 0, 9, 3);
		Location battleship26 = new Chamber("Gevechtsschip26", "battleship26.txt", 56, 57, 65, 55, 0, 0, 0, 0);
		Location battleship27 = new Chamber("Gevechtsschip27", "battleship27.txt", 57, 56, 58, 0, 0, 0, 0, 14);
		Location battleship28 = new Chamber("Gevechtsschip28", "battleship28.txt", 58, 57, 59, 60, 0, 0, 0, 0);
		Location battleship29 = new Chamber("Gevechtsschip29", "battleship29.txt", 59, 58, 0, 0, 0, 0, 0, 10);
		Location battleship30 = new Chamber("Gevechtsschip30", "battleship30.txt", 60, 58, 61, 0, 0, 0, 0, 0);
		Location battleship31 = new Chamber("Gevechtsschip31", "battleship31.txt", 61, 60, 62, 63, 0, 0, 0, 13);
		Location battleship32 = new Chamber("Gevechtsschip32", "battleship32.txt", 62, 61, 0, 0, 0, 0, 0, 15);
		Location battleship33 = new Chamber("Gevechtsschip33", "battleship33.txt", 63, 61, 64, 0, 0, 0, 0, 0);
		Location battleship34 = new Chamber("Gevechtsschip34", "battleship34.txt", 64, 63, 65, 0, 0, 0, 0, 9);
		Location battleship35 = new Chamber("Gevechtsschip35", "battleship35.txt", 65, 56, 64, 66, 0, 0, 0, 13);
		Location battleship36 = new Chamber("Gevechtsschip36", "battleship36.txt", 66, 65, 0, 0, 0, 0, 15, 0);
		Location battleship37 = new Chamber("Gevechtsschip37", "battleship37.txt", 67, 36, 68, 0, 0, 0, 0, 15);
		Location battleship38 = new Chamber("Gevechtsschip38", "battleship38.txt", 68, 67, 69, 0, 0, 0, 0, 8);
		Location battleship39 = new Chamber("Gevechtsschip39", "battleship39.txt", 69, 68, 70, 0, 0, 0, 0, 0);
		Location battleship40 = new Chamber("Gevechtsschip40", "battleship40.txt", 70, 69, 71, 0, 0, 0, 0, 16);
		BattleShipGun bsg0 = new BattleShipGun("Plasmakanon", "Grote damage waarde, maar alleen 50% kans om te raaken.", 20, 0.5);
		BattleShipGun bsg1 = new BattleShipGun("Doelgerichte Laser", "Kleine damage waarde, maar je raakt altijd!", 5, 1);
		BattleShipGun[] bsgArray = {bsg0, bsg1};
		BattleShip enemyship1 = new BattleShip("", "", 0, 0, 0, 0, 0, 0, 0, 0, 16., null, bsgArray);
		BattleShip enemyship2 = new BattleShip("", "", 0, 0, 0, 0, 0, 0, 0, 0, 37., null, bsgArray);
		BattleShip enemyship3 = new BattleShip("", "", 0, 0, 0, 0, 0, 0, 0, 0, 67.5, null, bsgArray);
		BattleShip[] ships = {enemyship1, enemyship2, enemyship3};
		Location battleship41 = new BattleShip("Controle Kamer", "battleshippanel.txt", 71, 70, 14, 0, 0, 0, 16, 0, 200., ships, bsgArray);
		Location lostciv2 = new Chamber("LostCiv2", "ZwartgatKamer1.txt", 72, 87, 73, 0, 0, 0, 0, 0);
		Location lostciv3 = new Chamber("LostCiv3", "ZwartgatKamer1.txt", 73, 75, 72, 0, 0, 0, 0, 14);
		Location lostciv4 = new Chamber("LostCiv4", "ZwartgatKamer2.txt", 74, 75, 0, 0, 0, 0, 0, 15);
		Location lostciv5 = new Chamber("LostCiv5", "ZwartgatKamer1.txt", 75, 76, 73, 74, 0, 0, 0, 0);
		Location lostciv6 = new Chamber("LostCiv6", "ZwartgatKamer3.txt", 76, 77, 75, 0, 0, 0, 17, 0);
		Location lostciv7 = new Chamber("LostCiv7", "ZwartgatKamer2.txt", 77, 78, 79, 76, 0, 0, 0, 16);
		Location lostciv8 = new Chamber("LostCiv8", "ZwartgatKamer1.txt", 78, 79, 77, 87, 0, 0, 0, 0);
		Location lostciv9 = new Chamber("LostCiv9", "ZwartgatKamer1.txt", 79, 77, 78, 84, 0, 0, 0, 17);
		Location lostciv10 = new Chamber("LostCiv10", "ZwartgatKamer1.txt", 80, 87, 82, 81, 0, 0, 0, 0);
		Location lostciv11 = new Chamber("LostCiv11", "ZwartgatKamer1.txt", 81, 80, 82, 83, 0, 0, 0, 0);
		Location lostciv12 = new Chamber("LostCiv12", "ZwartgatKamer3.txt", 82, 81, 84, 80, 0, 0, 0, 18);
		Location lostciv13 = new Chamber("LostCiv13", "ZwartgatKamer1.txt", 83, 81, 84, 0, 0, 0, 0, 19);
		Location lostciv14 = new Teleport("LostCiv14", "ZwartgatKamer2.txt", 84, 79, 82, 83, 85, 0, 0, 0, 5);
		Location lostciv15 = new Chamber("LostCiv15", "ZwartgatKamer1.txt", 85, 86, 0, 0, 0, 0, 0, 20);
		Location lostciv16 = new Chamber("LostCiv16", "ZwartgatKamer1.txt", 86, 0, 0, 0, 0, 0, 0, 20);
		Location lostciv1 = new LostCiv("LostCiv1", "Zwartgatmainlevel.txt", 87, 72, 78, 80, 0, 0, 0, 0);
		locations = new ArrayList<Location>();
		locations.add(chamber1);
		locations.add(chamber2);
		locations.add(chamber3);
		locations.add(chamber4);
		locations.add(teleport5);
		locations.add(chamber6);
		locations.add(chamber7); // tevens de plek waar de sleutel ligt
		locations.add(chamber8);
		locations.add(chamber9);
		locations.add(chamber10);
		locations.add(chamber11);
		locations.add(ruimteschip);
		locations.add(schip1);
		locations.add(schip2); // alien ruimte
		locations.add(artichokeplanet1);
		locations.add(artichokeplanet2);
		locations.add(artichokeplanet3);
		locations.add(artichokeplanet4);
		locations.add(artichokeplanet5);
		locations.add(artichokeplanet6);
		locations.add(artichokeplanet7);
		locations.add(artichokeplanet8);
		locations.add(artichokeplanet9);
		locations.add(artichokeplanet10);
		locations.add(artichokeplanet11); // hier ligt de shrinkgun
		locations.add(artichokeplanet12); // hier krijg je het vangnet
		locations.add(SaveCiv);
		locations.add(battleshipquest1);
		locations.add(battleshipquest2);
		locations.add(battleshipquest3);
		locations.add(battleship1);
		locations.add(battleship2);
		locations.add(battleship3);
		locations.add(battleship4);
		locations.add(battleship5);
		locations.add(battleship6);
		locations.add(battleship7);
		locations.add(battleship8);
		locations.add(battleship9);
		locations.add(battleship10);
		locations.add(battleship11);
		locations.add(battleship12);
		locations.add(battleship13);
		locations.add(battleship14);
		locations.add(battleship15);
		locations.add(battleship16);
		locations.add(battleship17);
		locations.add(battleship18);
		locations.add(battleship19);
		locations.add(battleship20);
		locations.add(battleship21);
		locations.add(battleship22);
		locations.add(battleship23);
		locations.add(battleship24);
		locations.add(battleship25);
		locations.add(battleship26);
		locations.add(battleship27);
		locations.add(battleship28);
		locations.add(battleship29);
		locations.add(battleship30);
		locations.add(battleship31);
		locations.add(battleship32);
		locations.add(battleship33);
		locations.add(battleship34);
		locations.add(battleship35);
		locations.add(battleship36);
		locations.add(battleship37);
		locations.add(battleship38);
		locations.add(battleship39);
		locations.add(battleship40);
		locations.add(battleship41);
		locations.add(lostciv1);
		locations.add(lostciv2);
		locations.add(lostciv3);
		locations.add(lostciv4);
		locations.add(lostciv5);
		locations.add(lostciv6);
		locations.add(lostciv7);
		locations.add(lostciv8);
		locations.add(lostciv9);
		locations.add(lostciv10);
		locations.add(lostciv11);
		locations.add(lostciv12);
		locations.add(lostciv13);
		locations.add(lostciv14);
		locations.add(lostciv15);
		locations.add(lostciv16);
	}

	public ArrayList<Location> getLocations() {
		return locations;
	}

	/**
	 *
	 * @param nr
	 * @return Een ArrayList met de connecterende kamers
	 */
	public ArrayList<Location> ArrayList(int nr) {
		Location location = getLocation(nr);
		int con1 = location.getCon1();
		int con2 = location.getCon2();
		int con3 = location.getCon3();
		int con4 = location.getCon4();
		int con5 = location.getCon5();
		connectingLocations = new ArrayList<Location>();
		for (Location l : locations) {
			if (con1 == l.getNr()) {
				connectingLocations.add(getLocation(l.getNr()));
			}
			if (con2 == l.getNr()) {
				connectingLocations.add(getLocation(l.getNr()));
			}
			if (con3 == l.getNr()) {
				connectingLocations.add(getLocation(l.getNr()));
			}
			if (con4 == l.getNr()) {
				connectingLocations.add(getLocation(l.getNr()));
			}
			if (con5 == l.getNr()) {
				connectingLocations.add(getLocation(l.getNr()));
			}
		}
		return connectingLocations;
	}

	public Location getLocation(int nr) {
		for (Location l : locations) {
			if (l.getNr() == nr) {
				return l;
			}
		}
		return null;
	}

	public ArrayList<Enemy> getEnemies() {
		return enemies;
	}

	public void setEnemies(ArrayList<Enemy> enemies) {
		Apl.boot.enemies = enemies;
	}

	public ArrayList<Location> getConnectingChambers() {
		return connectingLocations;
	}

	public void setItems(ArrayList<Item> items) {
		this.items = items;
	}

	public ArrayList<Item> getItems() {
		return items;
	}

	public void setCharacter(Character character) {
		this.character = character;
	}

	public Character getCharacter() {
		return character;
	}
}
